//
// Created by edward on 22-11-22.
//

#ifndef CONCURRENCE_SINGLETON_V2_H
#define CONCURRENCE_SINGLETON_V2_H

#include <memory>

namespace edward {

    template<typename T>
    class Singleton {
        using Ptr = std::shared_ptr<T>;

    public:
        static Ptr getInstance() {
            static Ptr p = std::make_shared<T>();    //对于静态变量的初始化只会进行一次
            return p;
        }
    };

}

#endif //CONCURRENCE_SINGLETON_V2_H
